package br.com.ericogr.hanoi.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
    private static final String BANCO_DE_DADOS = "torre-de-hanoi-brz";
    private static final int VERSAO = 1;
    private static final String SCRIPT_TABELA_PONTUACAO_V1 = 
            "create table pontuacao (\n" +
            " _id integer,\n" +
            " pratos integer not null,\n" +
            " movimentos integer not null,\n" +
            " tempo integer not null,\n" +
            " data date not null,\n" +
            " constraint pontuacao_pk primary key (_id),\n" +
            " constraint pontuacao_ch1 check (pratos >= 3 and movimentos >= 7 and tempo > 0)," +
            " constraint pontuacao_un1 unique (pratos))";
    
    public DatabaseHelper(Context context) {
        super(context, BANCO_DE_DADOS, null, VERSAO);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SCRIPT_TABELA_PONTUACAO_V1);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        
    }

}
